package com.phoenix.seata.controller;

import com.phoenix.seata.Entity.User;
import com.phoenix.seata.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/***
 * @Auther: 汪孟飞
 * @Description:
 * @Date: 2025-05-24 15:27
 * @Copyright:
 ***/
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/users")
    public String createUser(@RequestBody User user){
        try {
            userService.createUser(user);
            return "User created successfully";
        }catch (Exception e){
            return "User creation failed: "+e.getCause().getMessage();
        }
    }
}
